package ca.jsbr.canvaswar.games.mission 
{
	import ca.jsbr.as2js_lib.display.canvas.view.SpriteView;
	import ca.jsbr.as2js_lib.utils.assets.AssetsFactory;
	import ca.jsbr.canvaswar.games.faction.Faction;
	import ca.jsbr.canvaswar.games.map.Map;
	import ca.jsbr.canvaswar.games.map.MapDescription;
	import ca.jsbr.canvaswar.games.unit.Unit;
	/**
	 * ...
	 * @author jsbr [jsricard@lvlstudio.com]
	 */
	public class Test2Mission extends Mission
	{
		private var _blueTank:Unit;
		private var _redTank:Unit;
		private var _redFaction:Faction;
		private var _blueFaction:Faction;
		
		public function Test2Mission() 
		{
			var asset:SpriteView = new SpriteView(AssetsFactory.getInstance().getAssets("tiles"), 6, 5);
			var mapDescriptor:MapDescription = new MapDescription(asset);
			mapDescriptor.load();
			
			_map = new Map(mapDescriptor);
			_map.generate(800, 480);
			addChild(_map);
			createBlueFaction();
			createRedFaction();
			_ready = true;
			//_map.getTile(5, 6).moveCost = 0;
			//addStartUnit();
			
		}
		
		private function createBlueFaction():void 
		{
			_blueFaction = new Faction("blue");
			_blueTank = new Unit(AssetsFactory.getInstance().getAssets("bluetank"));
			_blueTank.position.x = 5;
			_blueTank.position.y = 5;
			_blueTank.orientation = Unit.RIGHT;
			_blueTank.move = 3;
			_map.addUnit(_blueTank);
			_blueFaction.addUnit(_blueTank);
		}
		
		private function createRedFaction():void 
		{
			_redFaction = new Faction("red");
			_blueTank = new Unit(AssetsFactory.getInstance().getAssets("redtank"));
			_blueTank.position.x = 8;
			_blueTank.position.y = 5;
			_blueTank.orientation = Unit.LEFT;
			_blueTank.move = 3;
			_map.addUnit(_blueTank);
			_redFaction.addUnit(_blueTank);
		}
		
		override public function destroy():void 
		{
			super.destroy();
		}
		
	}

}